package com.binyouwei.designpatterns.behavior.responsibility_link;

/**
 * @author 宾有为
 * @date 2024/7/17 20:01
 * @link https://blog.csdn.net/baidu_41616022?type=blog
 * @describe：责任链模式 - 允许将请求沿着处理者链传递，直到请求被处理为止。
 **/
public class ResponsibilityMain {
    public static void main(String[] args) {
        ResponsibilityHandler handlerA = new ConcreteHandlerA();
        ResponsibilityHandler handlerB = new ConcreteHandlerB();

        handlerA.setSuccessor(handlerB);

        handlerA.handleRequest(5);  // 应该由handlerA处理
        handlerA.handleRequest(15); // 应该由handlerB处理
        handlerA.handleRequest(25); // 无处理者，输出可能为空或错误
    }
}
